<template>
	<view class="good-list">
		<view class="good-li" v-for="item in list" :key="item.id">
			<view @click="btn(item.id)">
				<image class="good-img" mode="widthFix" :src="item.goodImg"></image>
				<view class="item">
					<view class="title">{{item.goodName}}</view>
					<text class="price">{{item.goodPrice}}元</text>
					<text class="sold">已售{{item.goodSold}}</text>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		name: "good-list",
		// 设置子组件接受父组件的选项
		props: {
			list: {
				type: Array,
				default () {
					return []
				}
			}
		},
		data() {
			return {

			}
		},
		methods: {
			btn(id) {
				console.log(id);
				uni.navigateTo({
					url: '/components/details/details?id=' + id
				})
			}
		}
	}
</script>
<style lang="scss">
	/* less和sass选择器可以父子嵌套 */
	.good-list {
		background-color: #fff;

		.good-li {
			display: flex;
			align-items: center;
			padding: 20upx;
			border-bottom: 1px solid #eee;

			.good-img {
				width: 160upx;
				height: 160upx;
				margin-right: 20rpx;
			}

			.item {
				flex: 1;

				.title {
					font-size: 26upx;
					line-height: 40upx;
					height: 80upx;
					margin-bottom: 20upx;
					overflow: hidden;
				}

				.price {
					font-size: 26upx;
					color: red;
				}

				.sold {
					font-size: 24upx;
					margin-left: 16upx;
					color: gray;
				}
			}
		}
	}
</style>